<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <style>
    /* 
        CSS选择器权重: 
                1.!important                权重：无穷大
                2.style行内样式              权重：1000
                3.id                        权重:100
                4.类=伪类=属性               权重:10
                5.标签=伪元素                权重:1
                6.默认样式=通配符            权重：0 
    */
    .box{
      color: pink;
    }
    #box{
      color: red;
    }
    div{
      color: orange /*!important*/;
    }
  </style>

  <div class="box" id="box" style="color: yellow;">CSS权重</div>


  <style>
    .box2{
      color: green;
    }
    [name="user"]{
      color: blue;
    }
  </style>
  <div class="box2" name="user">CSS权重</div>


  
  <style>
    /* 
      选择器权重是可以叠加的

    */
    /* 权重=类+标签  (10+1) */
    .box3 > span{
      color: chartreuse;
    }
    /* 权重=标签  1 */
    span{
      color: cornflowerblue;
    }
  </style>

  <div class="box3">
    <span>CSS权重</span>
  </div>
</body>
</html>